package com.guosheng;

import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Stack;

public class Solution {
    public static  void main(String[] args){
        int []arr=new int[]{4,8,6,12,16,14,10};
        VerifySquenceOfBST(arr);
    }
    public static boolean VerifySquenceOfBST(int [] sequence) {
        //中序和后续序列能够重构一个二叉树，但是
        //搜索二叉树有特性，二叉搜索树的左子树小于根节点，右子树大于根节点
        for(int i=0;i<sequence.length;){
            if(i==sequence.length-2)break;
            if(sequence[i]>sequence[i+2]||sequence[i+1]<sequence[i+2]){
                return false;
            }
            i=i+2;

        }
        return true;

    }

}